<template>
	<view style="font-size: 35upx;">
		<!-- #ifdef MP-WEIXIN -->
			<view class="" v-if="!userInfo" style="position: absolute; padding: 30upx 10upx; width: 500upx; height: 380upx; top: 30%; text-align: center; border-radius: 30upx; margin-left: 140upx; z-index: 9999; background-color: #ffffff;">
				<image style="width: 140upx; height: 140upx;"
				 :src="imglink + 'person.svg'" mode=""></image>
				<view class="" style="font-size: 40upx; font-weight: bold; color: rgba(0,0,0,0.85); margin-top: 20upx;">
					您还未登录
				</view>
				<view style="font-size: 28upx;color: rgba(0,0,0,0.45);">
					需要登录后才能查看
				</view>
				<button style="width: 370upx; z-index: 9999; margin-top: 30upx; font-size: 28upx; background: #02C15F;border-radius: 8px;"
				  type="primary" open-type="getUserInfo" 
				  @click="getuserinfo">授权登录</button>
			</view>
		<!-- #endif -->
		<image src="" style="width: 100%; height: 180upx; z-index: -99;" v-if="share == 0 && check == 2">
			<view class="box-shadow" style="background-image: url(https://tool.tuanhaoke.cn/static/image/recommend/background_top.png);">
				<view class="position">
					<view class="position-mag" @click="location" >
						<image :src="imglink + 'recommend/location.svg'" style="width: 50upx;height: 50upx;vertical-align: middle;"></image>
						<view style="display: inline-block; height: 50upx; width: 150upx; overflow: hidden; margin: 0 10upx;vertical-align: middle;color: #FFFFFF;z-index: 1;">{{locaAddress | getStr(4)}}</view>
						<image :src="imglink + 'recommend/down.svg'" style="width: 50upx;height: 50upx;vertical-align: middle;"></image>
					</view>
						<navigator style="display: inline-block;margin-left: 350upx;" url="/pages/recommend/specific/investigation">
							<image :src="imglink + 'recommend/search.png'" class="inves-img"></image>
						</navigator>
				</view>
				<scroll-view scroll-x="true" class="listda" show-scrollbar="false">
					<view class="list-f" v-for="(item,index) in subjectlist" :key="index">
						<view class="subject-reversal" :class="{'reversal': item.id == topnum}">
							<view @click="choseForm(item)">
								<view>{{item.name}}</view>
								<view style="" :class="{'subject-bottom' : item.id == topnum}"></view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</image>
		 <!-- -->
		<!-- #ifdef MP-WEIXIN -->
			<view @click="openSetting" v-if="authorization && share != 1 && check == 2" style="padding: 15upx 20upx;font-size: 26upx; background-color: #FFEFBD;color: #FB3B3B;">
				<image style="width: 30upx; height: 30upx; margin-right: 10upx; vertical-align: bottom;" src="http://tool.tuanhaoke.cn/static/image/sound.svg" mode=""></image>
				开启定位服务后才能看到附近的视频及内容
				<view class="go-open">
					去开启
				</view>
			</view>
		<!-- #endif -->
		<!-- 所有视频 -->
		<scroll-view :class=" share == 0 ? 'noshare-video' : 'share-video'"
			scroll-y="true"
			v-if="share == 1 && allvideolist.length > 0 && check == 2"
			@scrolltolower="LoadingStoreVideo">
			<view class="video" v-for="(item,index) in allvideolist" :key="index">
				<view class="video-label">
					{{ item.subjects_name }}
				</view>
				<image class="video-img" :src="item.head_img" mode="" @click="jumpVideo(item,index,4,allvideolist.length)"></image>
				<view class="video-nav" v-if="item.distance">
					<image :src="imglink + 'location_Hui.png'" class="video-nav-img"></image>
					<view class="video-nav-text">
						{{ item.distance | getdec() }}
					</view>
				</view>
				<view class="" style="padding: 10upx 0; margin-top: -10upx; background-color: #ffffff;" @click="jumpMechanism(item.store_id)">
					<image class="video-icon" :src="item.store_logo" mode=""></image>
					<view class="video-title">
						{{ item.store_name | getStr(14) }}
					</view>
				</view>
			</view>
			<view class="" style="height: 50upx;"></view>
		</scroll-view>
		<!-- 推荐视频 -->
		<scroll-view :class=" share == 0 ? 'noshare-video' : 'share-video'"
			scroll-y="true" 
			v-if="topnum == 1 && videolist.length > 0 && share == 0 && check == 2"
			@scrolltolower="LoadingRecommend">
			<view class="video" v-for="(item,index) in videolist" :key="index">
				<view class="video-label">
					{{ item.subjects_name }}
				</view>
				<image class="video-img" :src="item.head_img" mode="" @click="jumpVideo(item,index,1,videolist.length)"></image>
				<view class="video-nav" v-if="item.distance">
					<image :src="imglink + 'location_Hui.png'" class="video-nav-img"></image>
					<view class="video-nav-text">
						{{ item.distance | getdec() }}
					</view>
				</view>
				<view class="" style="padding: 10upx 0; margin-top: -10upx; background-color: #ffffff;" @click="jumpMechanism(item.store_id)">
					<image class="video-icon" :src="item.store_logo" mode=""></image>
					<view class="video-title">
						{{ item.store_name | getStr(14) }}
					</view>
				</view>
			</view>
			<view class="" style="height: 50upx;"></view>
		</scroll-view>
		<!-- 关注视频 -->
		<scroll-view :class=" share == 0 ? 'noshare-video' : 'share-video'"
			v-if="topnum == 2 && followVideo.length > 0 && check == 2"
			scroll-y="true"
			@scrolltolower="LoadingFollow">
			<view class="video" v-for="(item,index) in followVideo" :key="index">
				<view class="video-label">
					{{ item.subjects_name }}
				</view>
				<image class="video-img" :src="item.head_img" mode="scaleToFill" @click="jumpVideo(item,index,2,followVideo.length)"></image>
				<view class="video-nav" v-if="item.distance">
					<image :src="imglink + 'location_Hui.png'" class="video-nav-img"></image>
					<view class="video-nav-text">
						{{ item.distance | getdec() }}
					</view>
				</view>
				<view class="" style="padding: 10upx 0; margin-top: -10upx; background-color: #ffffff;" @click="jumpMechanism(item.store_id)">
					<image class="video-icon" :src="item.store_logo" mode=""></image>
					<view class="video-title">
						{{ item.store_name | getStr(14) }}
					</view>
				</view>
			</view>
			<view class="" style="height: 50upx;"></view>
		</scroll-view>
		<!-- 科目视频 -->
		<!-- style="background-color: #eaeaea; height: 79vh;"  -->
		<scroll-view :class=" share == 0 ? 'noshare-video' : 'share-video'"
			v-if="topnum != 1 && topnum != 2 && subjectVideo.length > 0 && check == 2"
			scroll-y="true"
			@scrolltolower="LoadingAubjectsVideo">
			<view class="video" v-for="(item,index) in subjectVideo" :key="index">
				<view class="video-label">
					{{ item.subjects_name }}
				</view>
				<image class="video-img" :src="item.head_img" mode="scaleToFill" @click="jumpVideo(item,index,3,subjectVideo.length)"></image>
				<view class="video-nav" v-if="item.distance">
					<image :src="imglink + 'location_Hui.png'" class="video-nav-img"></image>
					<view class="video-nav-text">
						<!-- {{ item.distance | transformDistance }} -->
						{{ item.distance | getdec() }}
					</view>
				</view>
				<view class="" style="padding: 10upx 0; margin-top: -10upx; background-color: #ffffff;" @click="jumpMechanism(item.store_id)">
					<image class="video-icon" :src="item.store_logo" mode=""></image>
					<view class="video-title">
						{{ item.store_name | getStr(14) }}
					</view>
				</view>
			</view>
			<view class="" style="height: 50upx;"></view>
		</scroll-view>
		<!-- 无视频 -->
		<view class="no-activity" v-if="share == 1 && allvideolist.length == 0 && check == 2">
			<view class="no-activity-img">
				<image :src="imglink + 'nothing-activity.png'" mode=""></image>
				<view class="">
					你还没有任何视频哦！
				</view>
			</view>
		</view>
		<view class="no-activity" v-if="topnum == 1 && videolist.length == 0 && share == 0 && check == 2">
			<view class="no-activity-img">
				<image :src="imglink + 'nothing-activity.png'" mode=""></image>
				<view class="">
					你还没有任何视频哦！
				</view>
			</view>
		</view>
		<view class="no-activity" v-if="topnum == 2 && followVideo.length == 0 && check == 2">
			<view class="no-activity-img">
				<image :src="imglink + 'nothing-activity.png'" mode=""></image>
				<view class="">
					你还没有任何视频哦！
				</view>
			</view>
		</view>
		<view class="no-activity" v-if="topnum != 1 && topnum != 2 && subjectVideo.length == 0 && check == 2">
			<view class="no-activity-img">
				<image :src="imglink + 'nothing-activity.png'" mode=""></image>
				<view class="">
					你还没有任何视频哦！
				</view>
			</view>
		</view>
		<view class="no-activity" v-if="check == 1">
			<view class="no-activity-img">
				<image :src="imglink + 'nothing-activity.png'" mode=""></image>
				<view class="">
					你还没有任何活动！
				</view>
			</view>
		</view>
		<tabBar :storeId='store_id'></tabBar>
	</view>
</template>

<script>
	import tabBar from '@/common/tabBar.vue'
	import { testLogin, userLogin, newInfo, login } from '@/common/login.js';
	export default {
		data() {
			return {
				userInfo:'',
				imglink: this.$store.state.imgLink,
				authorization: false,
				topnum: 1,
				store_id: 0,
				// 推荐视频
				recomPage:1,
				recomPagesize:10,
				recomLastPage:'',
				follPage:1,
				follPagesize:10,
				follLastPage:'',
				recomIds:[
					
				],
				videolist:[
					
				],
				store_video_current_page:1,
				followVideo:[],
				followIds:[
					
				],
				sub:[],
				// 推荐关注
				subjectlist:[
					{
						create_time:'',
						id:1,
						is_check:0,
						name:'推荐'
					},
					{
						create_time:'',
						id:2,
						is_check:1,
						name:'关注'
					},
				],
				// 科目
				subject:[],
				locaAddress:'定位中',
				longitude:'',
				latitude:'',
				dingwei:[],
				share: 0,
				subjectVideo:[],
				aubjectsPage: 1,
				aubjectsLastPage:'',
				
				allvideolist:[],
				allrecomLastPage:'',
				allrecomPage:'',
				custom_id:'',
				check:1
			}
		},
		// #ifdef MP-WEIXIN
			onShareAppMessage(res) {
				// this.setActivityShare()
				return {
					// title: this.itemAct.name,
					title: this.customer_info.nickname + '邀请您加入' + this.itemAct.name + '活动', // 分享描述
					path: '/pages/home/organization/activeDetail-3?store_id=' + this.$store.getters.getStoreId +
						'&actId=' + this.itemAct.activity_id + '&share_id=' + this.$store.getters.getCustomerId +
						'&page=share' + '&invite_type=activity', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imageUrl: this.itemAct.image[0].image,
				}
			},
		// #endif
		onLoad(option) {
			// #ifdef H5
				this.$store.commit('updataShare', 1)
			// #endif
			let store_id = parseInt(option.store_id,10);
			console.log('进入了onload 获取url的store_id',store_id)
			if(!store_id > 0){
				store_id = uni.getStorageSync('store_id')?parseInt(uni.getStorageSync('store_id'),10):0
			}else{
				uni.setStorageSync('store_id', store_id)
			}
			// this.locaAddress = uni.getStorageSync('locaAddress')
			// this.dingwei = uni.getStorageSync('dingwei')
			let is_extension = option.is_extension
			if( option.shopShare == '1' ){
				this.$store.commit('updataShare', 1)
			}
			this.findSetting()
			this.share = this.$store.state.share
			this.store_id = parseInt(store_id,10)
			this.$store.commit('updateStoreId',store_id)
			this.userInfo = uni.getStorageSync("userInfo")
			if(!is_extension){
				this.gainUserStore()
			}else{
				uni.setStorageSync('is_extension',is_extension)
				this.$store.commit('updataShare', 0)
				this.share = 0
				this.check = 2
			}
			let that = this
			// #ifdef H5
				if(option.type == 2){
					that.locaAddress = decodeURI(option.poiname);
					that.longitude = option.lng;
					that.latitude = option.lat;
					that.dingwei.push(option.lat,option.lng)
					console.log(that.dingwei,'**************************************************');
					// that.getGeocoders()
					uni.setStorageSync('locaAddress',this.locaAddress)
					uni.setStorageSync('dingwei',this.dingwei)
					that.getRecommend()
					that.getStoreVideo()
					that.getFollow()
					that.getAllAubjects()
				}else{
					wx.getLocation({
						type: 'gcj02',
						isHighAccuracy: true,
						success: function (res) {
							// console.log(res)
							// console.log('当前位置的经度：' + res.longitude);
							// console.log('当前位置的纬度：' + res.latitude);
							
							that.longitude = res.longitude;
							that.latitude = res.latitude;
							if( that.locaAddress == '定位中'){
								// console.log(that.dingwei,'**************************************************');
								that.dingwei.push(that.latitude,that.longitude)
								that.getGeocoders()
								uni.setStorageSync('dingwei',that.dingwei)
							}
							that.getRecommend()
							that.getStoreVideo()
							that.getFollow()
							that.getAllAubjects()
						},
						fail(res) {
							that.getRecommend()
							that.getStoreVideo()
							that.getFollow()
							that.getAllAubjects()
							console.log(res,'接口调用失败');
							// uni.showToast({
							// 	title:'定位失败!',
							// 	icon:'none',
							// 	duration:1000,
							// })
						}
					});
				}
			// #endif
		},
		onShow() {
			let that = this
			// #ifdef MP-WEIXIN
				wx.getLocation({
					type: 'gcj02',
					isHighAccuracy: true,
					success: function (res) {
						// console.log(res)
						// console.log('当前位置的经度：' + res.longitude);
						// console.log('当前位置的纬度：' + res.latitude);
						
						that.longitude = res.longitude;
						that.latitude = res.latitude;
						if( that.locaAddress == '定位中'){
							// console.log(that.dingwei,'**************************************************');
							that.dingwei.push(that.latitude,that.longitude)
							that.getGeocoders()
							uni.setStorageSync('dingwei',that.dingwei)
						}
						that.getRecommend()
						that.getStoreVideo()
						that.getFollow()
						that.getAllAubjects()
					},
					fail(res) {
						that.getRecommend()
						that.getStoreVideo()
						that.getFollow()
						that.getAllAubjects()
						console.log(res,'接口调用失败');
						// uni.showToast({
						// 	title:'定位失败!',
						// 	icon:'none',
						// 	duration:1000,
						// })
					}
				});
			// #endif
			
			that.getCustomer()
			that.getStore()
			// #ifdef MP-WEIXIN
			wx.hideHomeButton()
				const chooseLocation = requirePlugin('chooseLocation');
				const location = chooseLocation.getLocation(); // 如果点击确认选点按钮，则返回选点结果对象，否则返回null
				console.log(location,"选取定位返回信息");
				if( location ){
					that.locaAddress = location.name
					that.longitude = location.longitude;
					that.latitude = location.latitude;
					let a = []
					a.push(location.latitude,location.longitude)
					that.dingwei = a
					console.log(that.dingwei,"选取定位");
					that.getRecommend()
					that.getFollow()
					uni.setStorageSync('locaAddress',that.locaAddress)
					uni.setStorageSync('dingwei',that.dingwei)
				}
			// #endif
		},
		filters:{
			getdec(distance){
				if( distance ){
					if(distance < 1000){
						console.log(distance+"米");
						return distance.toFixed(0) + 'm'
					}
					else if(distance > 1000){
						console.log((Math.round(distance/100)/10).toFixed(1) + "公里")
						return (Math.round(distance/100)/10).toFixed(1) + "km"
					}
				}
			},
			getStr(str, new_length) {
			
				// console.log('getStr', str);
				if (!str) {
					return ''
				}
				if (str.length > new_length) {
					return str.slice(0, new_length) + '...'
				} else {
					return str
				}
			},
		},
		methods: {
			findSetting(){
				let data  = {
					
				}
				this.$api.find_setting(data).then(res => {
					console.log(res,"3333333333333333333333333333333");
					this.check = res
					// if(res.status){
					// 	this.check = res.check
					// 	console.log(this.check,"3333333333333333333333333333333");
					// }else{
					// 	uni.showToast({
					// 		title:res.msg,
					// 		icon:'none',
					// 		duration:2000
					// 	})
					// }
				}).catch(err => {
					console.log(err)
				})
			},
			gainUserStore() {
				// #ifdef H5
				let data = {
					token:this.$store.getters.getToken,
					type:2,
				}
				// #endif
				// #ifdef MP-WEIXIN
				let data = {
					token:this.$store.getters.getToken,
					type:1,
				}
				// #endif
				console.log('get_user_store',data);
				this.$api.get_user_store(data).then(res => {
					console.log('get_user_store',res);
					if (res.status) {
						this.$store.commit('updateStoreId',res.data);
						this.$store.commit('updataShare', 1)
						uni.setStorageSync("shopID",res.store_id)
						console.log(this.$store.getters.getStoreId,'this.$store.getters.getShopId')
					}
				})
				.catch(err => {
					console.log(err);
				});
			},
			getuserinfo() {
				
				//#ifdef MP-WEIXIN
				userLogin().then((res)=>{
					console.log(res)
					console.log(555555)
					this.share=0;
					this.check=2;
					this.userInfo=uni.getStorageSync("userInfo")
					this.getRecommend()
					this.getStoreVideo()
					this.getFollow()
					this.getAllAubjects()
				});	
				//#endif
			},
			openSetting(){
				wx.openSetting({
					success (res) {
						
						console.log(res.authSetting)
					}
				})
			},
			async getCustomer() {
				const data = {
					token: this.token,
					// customer_id:this.store_info.customer_id,
					store_id: this.store_id
				}
				this.$api.getCustomerInfo(data).then(res => {
					// console.log(res)
					if (res.status) {
						//获取活动信息
						this.customer_info = res.data
						this.custom_id = this.customer_info.userinfo.customer_id
						this.$store.commit('updataUserInfo', this.customer_info.userinfo);
						uni.setStorageSync('userInfo', this.customer_info.userinfo)
						//判断用户是否为店主
						if (this.customer_info.role == 3) {
							this.is_current_store_owner = 1
						}
					}
				}).catch(err => {
					console.log(err)
				})
				// let customer_info = this.$api.getCustomerInfo(data)
				// console.log(this.customer_info)
			
			},
			async getStore() {
				try {
					const data = {
						customer_store_id: this.store_id
					}
					console.log(data,"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
					this.$api.gain_shop_msg(data).then(res => {
						// console.log(res)
						if (res.status) {
							this.store_info = res.data
							this.$store.commit('updataCustomerId', this.store_info.customer_id);
							uni.setStorageSync('customer_id', this.store_info.customer_id)
			
						}
					}).catch(err => {
						console.log(err)
					})
					// let store_info = (await this.$api.gain_shop_msg(data)).data
					// this.store_info = store_info
			
				} catch (e) {
					console.log(e);
				}
			
			},
			// 逆地址解析
			getGeocoders(){
				let data  = {
					token:this.$store.getters.getToken,
					lat: this.latitude,
					lng: this.longitude
				}
				this.$api.get_geocoder(data).then(res => {
					if(res.status){
						this.locaAddress = res.localAddress
						console.log("对",res.localAddress);
						uni.setStorageSync('locaAddress',this.locaAddress)
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none',
							duration:2000
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 定位
			location(){
				this.aubjectsPage=1
				this.recomPage=1
				
				// #ifdef H5
					uni.navigateTo({
						url: 'address?type=1'
					})
				// #endif
				// #ifdef MP-WEIXIN
					const key = 'FROBZ-HAA35-37SI6-QXLMI-DQNAF-W3BUG'; //使用在腾讯位置服务申请的key
					const referer = '团好课课拍'; //调用插件的app的名称
					wx.navigateTo({
					  url: 'plugin://chooseLocation/index?key=' + key + '&referer=' + referer
					});
				// #endif
				
			},
			choseForm(item){
				this.topnum = item.id
				console.log(this.topnum);
				if(item.id == 2){
					this.getFollow()
				}
				this.getAubjectsVideo()
				// #ifdef MP-WEIXIN
					// this.sub = []
					// this.videolist.forEach((a) => {
					// 	if( a.subjects_id == this.topnum ){
					// 		this.sub.push(a)
					// 	}
					// })
				// #endif
				// #ifdef H5
					// this.sub = this.videolist.filter(data => data.subjects_id == topnum)
				// #endif
			},
			// 获取科目
			getAllAubjects(){
				let data  = {
					token:this.$store.getters.getToken,
				}
				this.$api.get_allAubjects(data).then(res => {
					// console.log(res)
					console.log("进来看了")
					if(res.status){
						this.subject = res.data
						console.log(this.subject,'科目');
						let su = this.subjectlist.concat(this.subject)
						this.subjectlist = su
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none',
							duration:2000
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 获取科目视频
			getAubjectsVideo(){
				// #ifdef MP-WEIXIN
					let data = []
					if( this.share == 0 ){
						data  = {
							token:this.$store.getters.getToken,
							long_lati:this.dingwei,
							// store_id: this.store_id,
							subjects_id:this.topnum,
							page:1,
							pagesize:10
						}
					}else{
						data  = {
							token:this.$store.getters.getToken,
							long_lati:this.dingwei,
							store_id: this.store_id,
							subjects_id:this.topnum,
							page:1,
							pagesize:10
						}
					}
				// #endif
				// #ifdef H5
					let data = []
					if( this.share == 0 ){
						data  = {
							token:this.$store.getters.getToken,
							long_lati:this.dingwei,
							// store_id: this.store_id,
							subjects_id:this.topnum,
							page:1,
							pagesize:10
						}
					}else{
						data  = {
							token:this.$store.getters.getToken,
							long_lati:this.dingwei,
							store_id: this.store_id,
							subjects_id:this.topnum,
							page:1,
							pagesize:10
						}
					}
				// #endif
				console.log(data);
				this.$api.get_subjects_video(data).then(res => {
					console.log(res)
					if(res.status){
						this.subjectVideo = res.data.data
						console.log(this.subjectVideo,'科目');
						this.aubjectsLastPage = res.data.last_page
					}else{
						uni.showToast({
							title:res.msg,
							icon:'none',
							duration:2000
						})
					}
				}).catch(err => {
					console.log(err)
				})
			},
			LoadingAubjectsVideo(){
				this.aubjectsPage ++
				console.log(this.aubjectsPage)
				if(this.aubjectsPage <= this.aubjectsLastPage){
					// #ifdef MP-WEIXIN
						let data = []
						if( this.share == 0 ){
							data  = {
								token:this.$store.getters.getToken,
								long_lati:this.dingwei,
								// store_id: this.store_id,
								subjects_id:this.topnum,
								page:1,
								pagesize:10
							}
						}else{
							data = {
								token:this.$store.getters.getToken,
								long_lati:this.dingwei,
								store_id: this.store_id,
								subjects_id:this.topnum,
								page:1,
								pagesize:10
							}
						}
					// #endif
					// #ifdef H5
						let data = {
								token:this.$store.getters.getToken,
								long_lati:this.dingwei,
								store_id: this.store_id,
								subjects_id:this.topnum,
								page:1,
								pagesize:10
							}
					// #endif
					this.$api.get_subjects_video(data).then(res=>{
						let vid = res.data.data
						this.subjectVideo = this.subjectVideo.concat(vid)
						console.log("上拉加载更多的数据.....")
						console.log(this.subjectVideo)
					}).catch(err => {
						console.log(err)
					})
				}else{
					uni.showToast({
						title:'没有更多了',
						icon:'none',
						duration:2000
					})
				}
			},
			
			getStoreVideo(){
				this.allrecomPage=1;
				let data = {
					token:this.$store.getters.getToken,
					long_lati:this.dingwei,
					store_id: this.store_id,
					page:1,
					pagesize:10
				}
				console.log("8888888",data);
				// 3.发送请求
				this.$api.select_store_video(data).then(res => {
					console.log(res,"545454");
					if(res.status){
						this.allvideolist = res.data.data
						this.authorization = false
						// let vid = res.data.data
						// this.videolist = vid.filter(data => data.status == 1)
						this.allrecomLastPage = res.data.last_page
						this.store_video_current_page=Number(res.data.current_page)+1
					}else{
						this.authorization = true
						uni.showToast({
							title:res.msg,
							icon:'none',
							duration:2000
						})
					}
				}).catch(err =>{
					console.log(err)
				})
			},
			LoadingStoreVideo(){
				this.allrecomPage ++
				console.log(this.allrecomPage)
				if(this.allrecomPage <= this.allrecomLastPage){
					let data = {
							token:this.$store.getters.getToken,
							long_lati:this.dingwei,
							// #ifdef MP-WEIXIN
							store_id: this.store_id,
							// #endif
							page:this.store_video_current_page,
							pagesize:10
						}
					this.$api.select_store_video(data).then(res=>{
						let vid = res.data.data
						this.store_video_current_page=Number(res.data.current_page)+1
						this.allvideolist = this.allvideolist.concat(vid)
						console.log("上拉加载更多的数据.....")
						console.log(this.allvideolist)
					}).catch(err => {
						console.log(err)
					})
				}else{
					uni.showToast({
						title:'没有更多了',
						icon:'none',
						duration:2000
					})
				}
			},
			// 获取推荐视频
			getRecommend(){
				// #ifdef MP-WEIXIN
					let data = []
					if( this.share == 0 ){
						data = {
							token:this.$store.getters.getToken,
							type:2,
							long_lati:this.dingwei,
							// store_id: this.store_id,
							page:1,
							pagesize:10
						}
					}else{
						data = {
							token:this.$store.getters.getToken,
							type:2,
							long_lati:this.dingwei,
							store_id: this.store_id,
							page:1,
							pagesize:10
						}
					}
				// #endif
				// #ifdef H5
					let data = []
					if( this.share == 0 ){
						data  = {
							token:this.$store.getters.getToken,
							long_lati:this.dingwei,
							// store_id: this.store_id,
							subjects_id:this.topnum,
							page:1,
							pagesize:10
						}
					}else{
						data  = {
							token:this.$store.getters.getToken,
							long_lati:this.dingwei,
							store_id: this.store_id,
							subjects_id:this.topnum,
							page:1,
							pagesize:10
						}
					}
				// #endif
				
				console.log("8888888",data);
				// 3.发送请求
				this.$api.get_recommend(data).then(res => {
					console.log(res,"545454");
					if(res.status){
						this.videolist = res.data.data
						this.authorization = false
						// let vid = res.data.data
						// this.videolist = vid.filter(data => data.status == 1)
						this.recomLastPage = res.data.last_page
					}else{
						this.authorization = true
						uni.showToast({
							title:res.msg,
							icon:'none',
							duration:2000
						})
					}
				}).catch(err =>{
					console.log(err)
				})
			},
			LoadingRecommend(){
				this.recomPage ++
				console.log(this.recomPage)
				if(this.recomPage <= this.recomLastPage){
					// #ifdef MP-WEIXIN
						let data = []
						if( this.share == 0 ){
							data = {
								token:this.$store.getters.getToken,
								type:2,
								long_lati:this.dingwei,
								// store_id: this.store_id,
								page:this.recomPage,
								pagesize:10
							}
						}else{
							data = {
								token:this.$store.getters.getToken,
								type:2,
								long_lati:this.dingwei,
								store_id: this.store_id,
								page:this.recomPage,
								pagesize:10
							}
						}
					// #endif
					// #ifdef H5
						let data = []
						if( this.share == 0 ){
							data = {
								token:this.$store.getters.getToken,
								type:2,
								long_lati:this.dingwei,
								// store_id: this.store_id,
								page:this.recomPage,
								pagesize:10
							}
						}else{
							data = {
								token:this.$store.getters.getToken,
								type:2,
								long_lati:this.dingwei,
								store_id: this.store_id,
								page:this.recomPage,
								pagesize:10
							}
						}
					// #endif
					this.$api.get_recommend(data).then(res=>{
						let vid = res.data.data
						this.videolist = this.videolist.concat(vid)
						console.log("上拉加载更多的数据.....")
						console.log(this.videolist)
					}).catch(err => {
						console.log(err)
					})
				}else{
					uni.showToast({
						title:'没有更多了',
						icon:'none',
						duration:2000
					})
				}
			},
			// 获取关注视频
			getFollow(){
				let data = {
					token:this.$store.getters.getToken,
					customer_id:this.custom_id,
					long_lati:this.dingwei,
					page:1,
					pagesize:this.follPagesize
				}
				// 3.发送请求
				console.log(data,"获取关注视频");
				this.$api.get_follow(data).then(res => {
					console.log(res,'获取关注视频')
					if(res.status){
						this.followVideo = res.data.data
						this.follLastPage = res.data.last_page
						console.log(this.followVideo,'关注视频')
					}else{
						// uni.showToast({
						// 	title:res.msg,
						// 	icon:'none',
						// 	duration:2000
						// })
					}
				}).catch(err =>{
					console.log(err)
				})
			},
			// 加载更多关注视频
			LoadingFollow(){
				this.follPage ++
				console.log(this.follPage)
				if(this.follPage <= this.follLastPage){
					let data = {
						token:this.$store.getters.getToken,
						customer_id: this.custom_id,
						long_lati:this.dingwei,
						page:this.follPage,
						pagesize:this.follPagesize
					}
					this.$api.get_follow(data).then(res=>{
						this.followVideo = this.followVideo.concat(res.data.data)
						console.log("上拉加载更多的数据.....")
						console.log(this.followVideo)
					}).catch(err => {
						console.log(err)
					})
				}else{
					uni.showToast({
						title:'没有更多了',
						icon:'none',
						duration:2000
					})
				}
			},
			// 跳转视频详情页
			jumpVideo(item,index,vid,length){
				this.aubjectsPage=1
				this.recomPage=1
				console.log('specific/videoshow?id=' + item.id + '&index=' + index + '&invid=' + vid + '&topnum=' + this.topnum + '&store_id=' + item.store_id + '&videolength='+length)
				uni.navigateTo({
					url: 'specific/videoshow?id=' + item.id + '&index=' + index + '&invid=' + vid + '&topnum=' + this.topnum + '&store_id=' + item.store_id + '&videolength=' + length + '&share=' + this.share
				})
			},
			// 跳转机构详情页
			jumpMechanism(id){
				uni.navigateTo({
					url: 'specific/mechanism?store_id=' + id
				})
			}
		},
		components: {
			tabBar
		},
	}
</script>

<style>
	@font-face {
		font-family:WowBold;
		src: url(https://tool.tuanhaoke.cn/static/image/font/Wow-Bold.svg);
	}
	.position{
		width: 100%;
		display: inline-block;
		vertical-align: middle;
		z-index: 9;
	}
	.position-mag{
		display: inline-block;
		margin: 20upx 0 20upx 20upx;
		font-size: 35upx;
		text-align: center;
		vertical-align: middle;
	}
	.position-input{
		border-radius: 20upx;
		display: inline-block;
		border: 1upx solid #000000;
		width: 400upx;
		margin-left: 80upx;
		margin-top: 10upx;
		vertical-align: middle;
	}
	.listda{
		width: 100%;
		margin-top: 20upx;
		margin-bottom: 20upx;
		display: inline-block;
		vertical-align: middle;
		overflow: hidden;
		white-space: nowrap;
		z-index: 9;
	}
	.list-f{
		margin: 0 30upx 0 30upx;
		display: inline-block;
	}
	.box-shadow{
		/* background-image: url(https://tool.tuanhaoke.cn/static/image//recommend/background_top.png); */
		/* background-color: #000000; */
		margin-top: -200upx;
		z-index: 999;
	}
	.subject-reversal{
		color: rgba(255,255,255,0.7);
		margin-right: 30upx;
		text-align: center;
	}
	.reversal{
		color: #FFFFFF;
		font-size: 40upx;
	}
	.subject-bottom{
		margin-top: 5upx;
		height: 2upx;
		width: 100%;
		background-color: #FFFFFF;
	}
	.inves-img{
		width: 35upx;
		height: 35upx;
		vertical-align: middle;
		margin: 10upx 0 0 0upx;
		background-color: rgba(255,255,255,0.5);
		border-radius: 60upx;
		padding: 10upx;
	}
	.video{
		position: relative;
		display: inline-block; 
		margin-top: 26upx;
		margin-left: 30upx;
		width: 330upx;
		overflow: auto;
		border-radius: 8upx;
		box-shadow: 0 4upx 18upx 0 rgba(0,0,0,0.13);
		vertical-align: middle;
	}
	.video-label{
		position: absolute; 
		z-index: 9;
		font-size: 24upx;
		color: #FF664F;
		margin-top: 14upx;
		margin-left: 10upx;
		padding: 4upx 16upx;
		border-radius: 20upx;
		background: rgba(255,255,255,0.70);
	}
	.video-img{
		height: 400upx;
		width: 330upx;
	}
	.video-nav{
		position: absolute;
		padding: 0upx 4upx 0upx 10upx;
		background: rgba(255,255,255,0.85);
		margin-top: -65upx;
		margin-left: 10upx;
		border-radius: 60upx;
		z-index: 9;
	}
	.video-nav-img{
		display: inline-block;
		width: 30upx;
		height: 30upx;
		margin-right: 5upx;
		margin-top: -6upx;
		vertical-align: middle;
	}
	.video-nav-text{
		display: inline-block;
		font-size: 24upx;
		margin-right: 10upx;
		margin-top: -6upx;
		vertical-align: middle;
		color: #FF664F;
	}
	.video-icon{
		width: 60upx;
		height: 60upx;
		margin-left: 10upx;
		vertical-align: middle;
		border-radius: 80upx;
		border: 1upx solid #cacaca;
	}
	.video-title{
		display: inline-block; 
		width: 238upx; 
		font-size: 26upx;
		margin-left: 15upx;
		vertical-align: middle;
	}
	.share-video{
		background-color: #eaeaea; 
		height: 92vh;
	}
	.noshare-video{
		background-color: #eaeaea; 
		height: 79vh;
	}
	.no-activity {
		height: 79vh;
		background-color: white;
	}
	.no-activity-img>image {
		width: 100%;
		height: 286upx;
		margin-top: 208upx;
	}
	.no-activity-img>view {
		color: #999999;
		font-size: 28upx;
		text-align: center;
	}
	.go-open{
		position: absolute;
		right: 20upx;
		font-size: 26upx;
		display: inline-block; 
		margin-top: -4upx;
		border-radius: 40upx;
		padding: 4upx 20upx;
		color: #ffffff;
		background-image: url(https://tool.tuanhaoke.cn/static/image/member/member-center.png);
	}
</style>
